#include "GMPingConnection.h"
#include "Factory.h"
#include "Timer.h"
#include "GMReturnPing.h"
#include "ClientManager.h"
#include "SendGameMessage.h"

#include <iostream>

GMPingConnection::GMPingConnection()
{

}

void GMPingConnection::Execute()
{

}

bool GMPingConnection::Read(SocketMessage* sm)
{
	int tempTS = 0;
	sm->ReadInt(&tempTS);
	m_timeStamp = (unsigned int)tempTS;
	GMReturnPing* gm = new GMReturnPing();
	gm->SetTimeStamp(m_timeStamp);
	SendGameMessage(*gm, &(TheClientManager::Instance()->GetSocket()));

	return true;
}

void GMPingConnection::Write(SocketMessage* sm)
{
	sm->WriteString("GMPingConnection");
	TheTimer::Instance()->UpdateTime();
	m_timeStamp = TheTimer::Instance()->GetTimeMS();
	sm->WriteInt(m_timeStamp);
}